<?php
class Base extends MY_Admin_Controller
{
    public function index()
    {
    	$page = intval($this->input->get_post('page'));
    	$page = $page ? $page : 1;
    	
    	$this->load->model('voice/Model_voice','voice');
    	$total_rows = $this->voice->count();
    	
    	//分页
    	$this->load->library('pagination');
    	 
    	$config['total_rows'] = $total_rows;
    	$config['per_page'] = 20;
    	$config['base_url'] = '/voice/Base/index';
    	 
    	$this->pagination->initialize($config);
    	$show_page = $this->pagination->create_links();
    	$offset = ($page-1) * $config['per_page'];
        
        $lists = $this->voice->lists($offset,  $config['per_page']);

        $data = array(
            'lists'    => $lists,
        	'show_page'   => $show_page,
        	'total_rows'  => $config['total_rows'],
        );

        $this->load->view('admin/voice/base/index',$data);
    }


    

    /*
     * 列表编辑状态保存
     *
     * */
    public function save_status()
    {
        $pid = (int)$this->input->get_post('aid');
      
        $data = array(
            'status'        =>      (int)$this->input->get_post('status'),
        );

        //更新user_info表
        $this->load->model('voice/Model_voice','voice');;
        $realData = $this->voice->getById($pid);

        //判断审核状态或者审核意见是否有变更
        if($realData['status'] != $data['status'])
        {
            $data['audit_uid']      = $this->uInfo['sid'];
            $data['audit_uname']    = $this->uInfo['login_name'];
            $data['audit_time']     = now_time();
        }

        $this->voice->save($data, $pid);
        $response = array('code' => '1', 'msg' => '修改成功');

        $this->json_output($response);
    }
}